//
//  ViewController.m
//  iOS-Interview
//
//  Created by Gechanghang on 2018/5/15.
//  Copyright © 2018年 CHANG HANG GE. All rights reserved.
//

#import "ViewController.h"
#import "Model.h"
#import "UIImage+Category.h"
@interface ViewController ()
@property (nonatomic, copy, readwrite) NSString *str;
@end


@implementation ViewController
@synthesize str = _str123;
- (void)viewDidLoad {
    [super viewDidLoad];
    // 1. copy 用法
    NSMutableString *testStr = [NSMutableString stringWithFormat:@"1234"];
    self.str = testStr;
    [testStr appendString:@"5"];
    NSLog(@"self.str=%@ testStr=%@",self.str,testStr);
    // Do any additional setup after loading the view, typically from a nib.
    
    //2.protocol 实现多重继承(属性的，需要synthesize实例变量)
    Model *people = [[Model alloc] init];
    people.name = @"byte";
    NSLog(@"people.name = %@",people.name);
    
    //3.给catrgroy添加属性
    UIImage *image = [UIImage new];
    image.debugName = @"345";
    NSLog(@"image.debugName = %@",image.debugName);
    
    //4. copy
    NSArray *array = @[@[@"a",@"b"],@[@"c",@"d"]];
    NSArray *copyArray = [array copy];//指针复制
    NSMutableArray *mCopyArray = [array mutableCopy];//内容拷贝，元素没变
    
    NSMutableArray *mArray = [NSMutableArray arrayWithObjects:[NSMutableString stringWithString:@"a"],@"b",@"c",nil];
    NSArray *cmArray = [mArray copy];//内容拷贝，元素没变
    NSMutableArray *mcmArray = [mArray mutableCopy];//内容拷贝，元素没变
    
    //5.synthesize 的用处 修改默认实例变量名
    _str123 = @"byte 123";
    NSLog(@"self.str = %@",self.str);
    
    //6. 消息转发
    [people performSelector:@selector(eat)];// 动态方法解析
    [people performSelector:@selector(run)];// 交给别人处理
    [people performSelector:@selector(code)];// 完整转发机制
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
